<%@ page language="java"
	import="java.util.*,news.dao.*,news.pojo.*,news.util.*"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gbk" />
<title>新闻中国</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script language="javascript">
	function check() {
		var login_username = document.getElementById("uname");
		var login_password = document.getElementById("upwd");
		if (login_username.value == "") {
			alert("用户名不能为空！请重新填入！");
			login_username.focus();
			return false;
		} else if (login_password.value == "") {
			alert("密码不能为空！请重新填入！");
			login_password.focus();
			return false;
		}
		return true;
	}

	function focusOnLogin() {
		var login_username = document.getElementById("uname");
		login_username.focus();
	}

	function souye() {
		location = 'home.jsp';
	}
</script>
</head>

<body onload="focusOnLogin()">

	<div id="header">
		<div id="top_login">
<%-- 			<%
				Cookie[] cookies = request.getCookies();
				String name = "";
				String pwd = "";
				if (cookies != null) {
					for (int i = 0; i < cookies.length; i++) {
						if (cookies[i].getName().equals("USER_NAME"))
							name = cookies[i].getValue();
						else if (cookies[i].getName().equals("USER_PASS"))
							pwd = cookies[i].getValue();
					}
				}
			%> --%>
			
			<div id="top_login">
			<c:choose>
				<c:when test="${uname!=null}">欢迎管理员${uname}&#160;&#160;&#160;&#160;
				 <a href="dologoutServlet">退出登录</a>&#160;&#160;&#160;&#160;&#160;&#160;
				<a href="adminServlet">进入后台</a>				
				</c:when>
				<c:otherwise>
					<form action="doLoginServlet" method="post"
						onsubmit="return check()">
						<label> 登录名 </label> <input type="text" name="uname" id="uname"
							value="${cookname}" class="login_input" /> <label>
							密&#160;&#160;码 </label> <input type="text" name="upwd" id="upwd"
							value="${cookpwd }" class="login_input" /> 						
							<span style="color:red;">${errmsg}</span><c:remove var="errmsg"/>
							<input type="checkbox"
							name="keep" id="keep" value="1" />记住我的登录状态 <input type="submit"
							class="login_sub" value="登录" /> <label id="error"> </label> <img
							src="JSP/images/friend_logo.gif" alt="Google" id="friend_logo" />
					</form>
				</c:otherwise>
			</c:choose>
				
			</div>
		</div>
		<div id="nav">
			<div id="logo">
				<img src="images/logo.jpg" alt="新闻中国" onclick="souye()" />
			</div>
			<div id="a_b01">
				<img src="images/a_b01.gif" alt="" />
			</div>
			<!--mainnav end-->
		</div>
	</div>
	<div id="container">
		<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
		<%-- <div class="sidebar">
			<h1>
				<img src="images/title_1.gif" alt="国内新闻" />
			</h1>
			<div class="side_list">

				<ul>
					<c:forEach items="${newslist1 }" var="newslist1">
						<li><a href='newsServlet?nid=${newslist1.nid }'><b>${newslist1.ntitle }</b></a>
						</li>
					</c:forEach>
				</ul>
			</div>
			<h1>
				<img src="images/title_2.gif" alt="国际新闻" />
			</h1>
			<div class="side_list">
				<ul>
					<c:forEach items="${newslist2 }" var="newslist2">
						<li><a href='newsServlet?nid=${newslist2.nid }'><b>${newslist2.ntitle }</b></a>
						</li>
					</c:forEach>
				</ul>
			</div>
			<h1>
				<img src="images/title_3.gif" alt="娱乐新闻" />
			</h1>
			<div class="side_list">
				<ul>
					<c:forEach items="${newslist5 }" var="newslist5">
						<li><a href='newsServlet?nid=${newslist5.nid }'><b>${newslist5.ntitle }</b></a>
						</li>
					</c:forEach>
				</ul>
			</div>
		</div> --%>
<jsp:include page="/leftServlet"></jsp:include>


		<div class="main">
			<div class="class_type">
				<img src="images/class_type.gif" alt="新闻中心" />
			</div>
			<div class="content">
				<ul class="class_date">
					<li id='class_month'>
					<c:forEach items="${topics}" var="topic"
							varStatus="s">
							<a href="indexServlet?pageno=${pa.pageno}&tid=${topic.tid}"> <b>${topic.tname}</b></a>
						</c:forEach></li>
				</ul>
				<ul class="classlist">
					<%-- <%
						Integer pageno = 1;
						Integer tid = null;
						Page<News> p = null;
						try {
							pageno = Integer.parseInt(request.getParameter("pageNo"));
						} catch (Exception e) {
						}
						try {
							tid = Integer.parseInt(request.getParameter("tid"));
						} catch (Exception e) {
						}
						if (tid != null) {
							p = NewsDao.nd.search2(pageno, tid);
						} else {
							p = NewsDao.nd.search1(pageno);
						}

						for (int i = 0; i < p.getP().size();) {
							News nq = p.getP().get(i);
					%>
					<li><a href='news.jsp?nid=<%=nq.getNid()%>'><%=nq.getNtitle()%>
					</a><span> <%=nq.getNcreateDate()%></span></li>
					<%
						i++;
							if (i % 5 == 0) {
								out.print("  <li class='space'></li> ");
					%>

					<%
						}
						}
					%>
					<p align="right">
						当前页数：[<%=p.getPageno()%>/<%=p.getTotalno()%>]
						<%System.out.print(p.getTotalno()) ;%>
						<%
						if (p.getPageno() > 1) {
					%>
						<a href="index.jsp?pageNo=<%=p.getPageno() - 1%><%=tid==null?"":"&tid="+tid%>">上一页</a>
						<%
							}
						%>
						<%
							if (p.getPageno() < p.getTotalno()) {
						%>
						<a href="index.jsp?pageNo=<%=p.getPageno() + 1%><%=tid==null?"":"&tid="+tid%>">下一页</a> <a
							href="index.jsp?pageNo=<%=p.getTotalno()%><%=tid==null?"":"&tid="+tid%>">末&nbsp 页</a>
						<%
							}
						%>
					</p> --%>
					<c:forEach items="${pa.p}" var="pnews" varStatus="s">
						<li><a href='newsServlet?nid=${pnews.nid }'>${pnews.ntitle}
						</a><span> <fmt:formatDate value="${pnews.ncreateDate }" pattern="yyyy-MM-dd HH:mm"/></span> <c:if test="${s.count%5==0}">
								<li class='space'></li>
								
							</c:if></li>
					</c:forEach>
					<p align="right">
					<c:if test="${pa.pageno>1}">
					<a
							href="indexServlet?pageno=${pa.pageno-1}&tid=${tid}">上一页</a>&#160;
					</c:if>
						<c:if test="${pa.pageno<pa.totalno }">
						<a
							href="indexServlet?pageno=${pa.pageno+1}&tid=${tid}">下一页</a>&#160;
							<a
							href="indexServlet?pageno=${pa.totalno}&tid=${tid}">末页</a>&#160;
						</c:if>
						当前页数:[ ${pa.pageno}/${pa.totalno}]
					</p>
				</ul>
			</div>
			<div class="picnews">
				<ul>
					<li><a href="#"><img src="images/Picture1.jpg" width="249"
							alt="" /> </a><a href="#">幻想中穿越时空</a></li>
					<li><a href="#"><img src="images/Picture2.jpg" width="249"
							alt="" /> </a><a href="#">国庆多变的发型</a></li>
					<li><a href="#"><img src="images/Picture3.jpg" width="249"
							alt="" /> </a><a href="#">新技术照亮都市</a></li>
					<li><a href="#"><img src="images/Picture4.jpg" width="249"
							alt="" /> </a><a href="#">群星闪耀红地毯</a></li>
				</ul>
			</div>
		</div>
	</div>
	<%@ include file="footer.jsp"%>
</body>
</html>
